function [ xn_frams ] = framing( xn,fs,fram_time,fram_step_time,win )
%FRAMING Summary of this function goes here
%   Detailed explanation goes here

%?????????????    
%                   [xn_frams] = framing(xn,fs,fram_time,fram_step_time,win)
%?????
%                   xn:??????
%                   fs:???
%                   fram_time:???
%                   fram_step_time:??????
%                   win:??????????????
%?????
%                   xn_frams:??????????????????xn?????
    [row col]=size(xn);
    if row>col xn=xn';
    else
    end

    ts=1/fs;

    l=length(xn);%??????
    xn_time=l*ts;%??????
    fram_length=ceil(fram_time/ts);%??????
    fram_step_length=ceil(fram_step_time/ts);%?????
    if win=='hanning' win=hanning(fram_length);
    elseif win=='hamming' win=hamming(fram_length);
    end
    %?????????????-???+???/??
    numOfframs=(l-fram_length+fram_step_length)/fram_step_length;%??????
    %??????????????????0???????
    numOfframs=ceil(numOfframs);
    %?????????????????
    l_added=(numOfframs*fram_step_length-fram_step_length+fram_length);%??????????
    l=l_added-l;
    xn=[xn,zeros(1,l)];%?0
    xn_time=ceil(l*ts);
    xn_frams=zeros(fram_length,numOfframs);%?????????

    %????
    for k=1:numOfframs
        dn=(k-1)*fram_step_length+(1:fram_length);
        xn_frams(:,k)=xn(dn).*win';
    end
end